/*
   CC.NET SideBar Gadget for Windows Vista 
   (C) Simone Chiaretta, 2007
   http://codeclimber.net.nz

   This project is licensed under the new BSD license.
   See the License.txt file for more information.

	this.RefreshInterval = 40;
	this.DisplayMode = DisplayModeEnum.OnlyFailing;
	this.AutoScrollEnabled = true;
	this.AutoScrollInterval = 10;
	this.ProjectList = this.DeserializeProjectList("");
	   
*/
var DisplayModeEnum = { All:0, OnlyFailing:1}

var Settings =
{
   RefreshInterval: 30,
   DisplayMode: DisplayModeEnum.All,
   AutoScrollEnabled: false,
   AutoScrollInterval: 5,
   ProjectList: new Array(),
   Save: function()
   {
      alert(this.SerializeProjectList());
   },
   Read: function()
   {
	this.RefreshInterval = 40;
	this.DisplayMode = DisplayModeEnum.OnlyFailing;
	this.AutoScrollEnabled = true;
	this.AutoScrollInterval = 10;
	this.ProjectList = this.DeserializeProjectList("ciao|proj;ciao|pro");
   },
   AddProjectSettings: function(project)
   {
	this.ProjectList[this.ProjectList.length]=project;
   },
   SerializeProjectList: function()
   {
		var projectListStr="";
		for(var i in this.ProjectList)
		{
			projectListStr+=this.ProjectList[i].serverUrl+"|"+this.ProjectList[i].projectName+";";
		}
		return projectListStr.substring(0,projectListStr.length-1);
   },
   DeserializeProjectList: function(listStr)
   {
		var projectList = new Array();
		if(listStr.length>0)
		{
			var projectListStr=listStr.split(";");
			for(var i in projectListStr)
			{
				var objParts = projectListStr[i].split("|");
				projectList[i] = new ProjectSettings(objParts[0],objParts[1]);
			}
		}
		return projectList;
   },
   Validate: function()
   {
	return true;
   }
}

var ProjectSettings = function(serverUrl, projectName)
{
   this.serverUrl = serverUrl;
   this.projectName = projectName;
   this.serverName = serverUrl.substring(0,serverUrl.length);
}

